

function bbCodeMarker(startMarker,endMarker,textareaId)
{
	var textarea = document.getElementById(textareaId);
	
	//IE javascript code
	if(document.selection)
	{
		
		textarea.focus();
		var select = document.selection.createRange();
		
		select.text = startMarker + select.text + endMarker;
	}
	else
	{
		//For Mozilla
		
		var len = textarea.value.length;
		var start = textarea.selectionStart;
		var end = textarea.selectionEnd;
		
		if((start-end)==0)
		{
			textarea.value = textarea.value + startMarker + endMarker;
		}
		else
		{
			var select = textarea.value.substring(start,end);
			
			if(startMarker=='[url]')
			{
				var url = prompt('Enter the full URL :');
				if(url)
				{
				select = '[url=' + url +']' + select + endMarker;
				}
				else
				{
					select = startMarker + select + endMarker;
				}
			}
			else if(startMarker=='[page]')
			{
				var page = prompt('Enter page full name :');
				if(page)
				{
				select = '[page=' + page +']' + select + endMarker;
				}
				else
				{
					select = startMarker + select + endMarker;
				}
			}
			else
			{
				select = startMarker + select + endMarker;
			}
			
			textarea.value = textarea.value.substring(0,start) + select + textarea.value.substring(end,len);
		}
	}
}